package com.rongsheng.mpchartdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.github.mikephil.charting.charts.HorizontalBarChart;

import java.util.ArrayList;
import java.util.List;

public class HorizontalBarChartActivity extends AppCompatActivity {
    private HorizontalBarChart mHorizontalBarChart;
    private List<String> yAxisValues;
    private List<Float> xAxisValues;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_horizontal_bar_chart);
        initView();
        initData();

        MPChartHelper.setHorizontalBarChart(mHorizontalBarChart,xAxisValues,yAxisValues,"柱状图（单）",15,null);
    }

    private void initData() {
        xAxisValues = new ArrayList<>();
        yAxisValues = new ArrayList<>();
        for(int i=1;i<10;++i){
            yAxisValues.add(String.valueOf(i));
            xAxisValues.add((float)(Math.random()*1000+20));
        }
    }

    private void initView() {
        mHorizontalBarChart = (HorizontalBarChart) findViewById(R.id.hor_bar_chart);
    }
}
